﻿using System;
using System.Web;
using System.Web.Caching;

namespace EasySL.Share
{
    public class CacheHelper
    {
        public static bool Contains(string key)
        {
            return HttpRuntime.Cache.Get(key) != null;
        }

        public static T Get<T>(string key)
        {
            return (T)HttpRuntime.Cache.Get(key);
        }

        public static void Insert(string key, object value)
        {
            HttpRuntime.Cache.Insert(key, value);
        }

        public static void Insert(string key, object value, CacheDependency dependencies)
        {
            HttpRuntime.Cache.Insert(key, value, dependencies);
        }

        public static void Insert(string key, object value, int minutes)
        {
            HttpRuntime.Cache.Insert(key, value, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(minutes));
        }

        public static void Remove(string key)
        {
            HttpRuntime.Cache.Remove(key);
        }
    }
}
